export interface ComponentConfig {
  type: string
  name: string
  icon: string
  defaultProps: Record<string, any>
  defaultSize: { width: number; height: number }
}

export interface CanvasComponent {
  id: string
  type: string
  props: Record<string, any>
  position: { x: number; y: number }
  size: { width: number; height: number }
  value: any
  isColliding?: boolean
  parentId?: string // 父组件ID，用于嵌套组件
  gridItemIndex?: number // 在栅格中的列索引
  children?: CanvasComponent[] // 子组件列表
}

export interface AlignmentGuides {
  vertical: number | null
  horizontal: number | null
}

export interface Option {
  label: string
  value: string
}

export interface MutexRule {
  value: string
  hiddenComponents: string[] // 组件ID数组
}

export interface MutexConfig {
  enabled: boolean
  rules: MutexRule[]
}

export interface RelateRule {
  currentOptionValue: string // 当前组件的选项值
  currentOptionLabel: string // 当前组件的选项标签
  dependentOptions: Option[] // 依赖组件的值数组（多选）
}

export interface RelateConfig {
  enabled: boolean  // 是否启用依赖规则
  dependentComponentId: string // 依赖组件的ID
  currentComponentId: string // 当前组件的ID
  currentComponentOptions: Option[] // 当前组件的选项
  rules: RelateRule[] // 依赖规则
}

// 内置验证规则类型
export type ValidationRuleType = 'none' | 'required' | 'email' | 'phone' | 'idcard'

// 验证规则配置
export interface ValidationRule {
  type: ValidationRuleType
  message?: string
}

// 扩展组件属性，添加验证规则
export interface ComponentProps {
  label: string
  field: string
  placeholder?: string
  required: boolean
  disabled: boolean
  readonly: boolean
  fontSize?: number
  color?: string
  backgroundColor?: string
  borderStyle?: string
  borderColor?: string
  borderWidth?: number
  borderRadius?: number
  padding?: number
  margin?: number
  widthType?: 'full' | 'custom'
  customWidth?: number
  labelPosition?: 'top' | 'left'
  labelWidth?: 100
  labelAlign?: 'left' | 'center' | 'right'
  minLength?: number
  maxLength?: number
  pattern?: string
  validationRule?: ValidationRule
  onClick?: string
  onChange?: string
  onFocus?: string
  onBlur?: string
  // 其他特定组件的属性
  rows?: number
  showWordCount?: boolean
  options?: Option[]
  layout?: 'horizontal' | 'vertical'
  min?: number
  max?: number
  step?: number
  precision?: number
  content?: string
  mutexConfig?: MutexConfig
  relateConfig?: RelateConfig
}